package com.example.mobile2021606127cxz0602homework;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {

    private TextView tvMainUser;
    private TextView tvMainPsw;
    private Button btnRelogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        Intent intent = getIntent();
        //第一种方式
        tvMainUser.setText(intent.getStringExtra("userName"));
        //第二种方式
        Bundle bundle = intent.getExtras();
        tvMainPsw.setText(bundle.getString("passWord"));
    }

    private void initView() {
        tvMainUser = (TextView) findViewById(R.id.tv_main_user);
        tvMainPsw = (TextView) findViewById(R.id.tv_main_psw);
        btnRelogin = (Button) findViewById(R.id.btn_relogin);
    }
    public void onRelogin(View view) {
        Intent intent = new Intent(MainActivity2.this,MainActivity.class);
        startActivity(intent);
    }
}